<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../include/laypublic.jsp" %>
<%@ include file="../include/vueComponent.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>预立项审批</title>
</head>
<style>
    #app {
        width: 100%;
        height: 100%;
        padding: 60px 20px 20px;
        box-sizing: border-box;
    }

    .head {
        position: fixed;
        top: 0;
        left: 20px;
        height: 50px;
        background: rgb(242, 242, 242);
        z-index: 99;
        width: calc(100% - 40px);
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 10px;
    }

    .head .left {
        border-bottom: 5px solid #2f9688;
        font-size: 17px;
        padding-bottom: 5px;
    }

    .container {
        width: 100%;
        background: white;
        padding: 10px;
        box-sizing: border-box;
    }

    .full {
        width: 100%;
        display: flex;
        justify-content: flex-start;
    }

    /*改变el-form-item的样式*/
    .el-form-item {
        margin-bottom: 4px;
    }

    .flex-center {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .mr-10 {
        margin-right: 10px;
    }

    .title {
        border-bottom: 1px solid #2f9688;
        margin-bottom: 30px;
    }

    h3 {
        background: #2f9688;
        display: inline-block;
        color: white;
        padding: 5px 10px;
        border-radius: 4px 4px 0 0;
        font-size: 14px;
    }

    .unit {
        width: calc(100% - 14.4% - 40px);
        margin: 0 8.33333% 0 calc(8.33333% - 40px);
        padding: 0 0 30px 0;

    }

    .unit .unit_center {
        display: flex;
        justify-content: flex-start;
    }

    .unit .unit_add {
        display: flex;
        justify-content: flex-end;
        margin-bottom: 10px;
    }

    .unit .unit_img {
        padding-top: 47.4px;
        width: 30px;
        margin-right: 10px;
    }

    .unit .unit_img div {
        line-height: 41px;

    }

    .unit .el-table thead {
        color: black !important;
        font-weight: normal !important;

    }

    .unit .el-table td {
        padding: 0 !important;
    }

    .unit .el-table__row > .td {
        padding: 0 !important;
    }

    .unit .el-table .el-input__inner {
        border: none;
        background-color: rgba(0, 0, 0, 0);
        text-align: center;
    }

    .investment {
        width: calc(100% - 14.4% - 40px);
        margin: 0 8.33333% 0 calc(8.33333% - 40px);
        padding: 0 0 30px 0;
    }

    .investment .investment_center {
        display: flex;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .investment_top_del {
        margin: 0 0 10px 40px;
        width: calc(100% - 140px);
        display: flex;
        justify-content: space-around;
        align-items: center;
    }

    .investment_top_del .item {
        flex: 1;
        text-align: center;
    }

    .investment .investment_add {
        display: flex;
        justify-content: flex-end;
        margin-bottom: 10px;
    }

    .investment .investment_img {
        padding-top: 64px;
        width: 30px;
        margin-right: 10px;
    }

    .investment .investment_img div {
        height: 41px;
        line-height: 41px;

    }

    .investment .el-table thead {
        color: black !important;
        font-weight: normal !important;

    }

    .investment .el-table td {
        padding: 0 !important;
    }

    .investment .el-table__row > .td {
        padding: 0 !important;
    }

    .investment .el-table .el-input__inner {
        border: none;
        background-color: rgba(0, 0, 0, 0);
        text-align: center;
    }

    .el-input.is-disabled .el-input__inner {
        color: #000;
    }

    .popover_item {
        padding: 0 10px;
    }

    .popover_item .el-button:active {
        color: #2f9688
    }

    .el-button:focus, .el-button:hover {
        color: #fff;
        border-color: #2f9688;
        background-color: #2f9688;
    }

    .layui-form-label {
        width: 180px;
    }
</style>
<body>
<div id="app">
    <div class="head">
        <div class="left">新增项目信息</div>
        <div class="right">
            <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" @click="save(0)">驳回</button>
            <button type="button" class="layui-btn layui-btn-radius"  @click="save(1)">通过</button>
        </div>
    </div>
    <div class="container">
        <el-form ref="formRef" label-width="140px" label-suffix="："
                 label-position="left">
            <%--项目基础信息--%>
            <div class="base-info">
                <div class="title">
                    <h3>项目基础信息</h3>
                </div>
                <!--表单-->
                <div>
                    <el-row>
                        <x-col>
                            <el-form-item label="项目编码">
                                <span>{{info.proCode}}</span>
                            </el-form-item>
                        </x-col>
                        <x-col position="right">
                            <el-form-item label="所属公司">
                                <span>{{info.compName}}</span>
                            </el-form-item>
                        </x-col>
                    </el-row>
                    <el-row>
                        <x-col>
                            <el-form-item label="项目名称">
                                <x-input v-model="info.proName" name="项目名称" disabled/>
                            </el-form-item>
                        </x-col>
                        <x-col position="right">
                            <el-form-item label="营销经理">
                                <span>{{info.staffName}}</span>
                            </el-form-item>
                        </x-col>
                    </el-row>
                    <el-row>
                        <x-col position="full">
                            <el-form-item label="项目地点">
                                <el-select v-model="info.refProvinceId" style="width: 100px" filterable disabled
                                           placeholder="请选择"
                                           @change="selProvince">
                                    <el-option v-for="item in province" :key="item.id" :label="item.sname"
                                               :value="item.id"></el-option>
                                </el-select>

                                <el-select v-model="info.refCityId" style="width: 100px" filterable placeholder="请选择"
                                           disabled
                                           @change="selCity">
                                    <el-option v-for="item in city" :key="item.id" :label="item.sname"
                                               :value="item.id"></el-option>
                                </el-select>
                                <el-select v-model="info.refAreaId" style="width: 100px" filterable placeholder="请选择"
                                           disabled>
                                    <el-option v-for="item in area" :key="item.id" :label="item.sname"
                                               :value="item.id"></el-option>
                                </el-select>
                                <el-input v-model="info.address" placeholder="请输入内容"
                                          style="width: calc(100% - 312px)" disabled></el-input>
                            </el-form-item>
                        </x-col>

                    </el-row>
                    <el-row>
                        <x-col>
                            <el-form-item label="项目类型">
                                <x-select v-model="info.proTypes" :options="projectType" name="项目类型"
                                          disabled></x-select>
                            </el-form-item>
                        </x-col>
                        <x-col position="right">
                            <el-form-item label="入库情况">
                                <x-select v-model="info.isInStore" :options="storageSituation" name="入库类型"
                                          disabled></x-select>
                            </el-form-item>
                        </x-col>

                    </el-row>
                    <el-row>
                        <x-col>
                            <el-form-item label="项目业态">
                                <x-select v-model="info.proFormat" :options="proFormaType" name="入库类型"
                                          disabled></x-select>
                            </el-form-item>
                        </x-col>
                        <x-col position="right">
                            <el-form-item label="运营周期">
                                <x-input v-model="info.omYears" name="运营周期" disabled/>
                            </el-form-item>
                        </x-col>

                    </el-row>
                    <el-row>
                        <x-col>
                            <el-form-item label="项目渠道">
                                <x-select v-model="info.fromChannel" :options="projectChannel" name="入库类型"
                                          disabled></x-select>
                            </el-form-item>
                        </x-col>
                        <x-col position="right">
                            <el-form-item label="业主单位名称">
                                <el-select v-model="info.unitId" style="width: 100%" filterable disabled
                                           placeholder="请选择业主单位">
                                    <el-option v-for="item in owner" :key="item.id" :label="item.coopName"
                                               :value="item.id"></el-option>
                                </el-select>
                                <%--                                <x-select v-model="info.unitId" :options="owner" name="入库类型"></x-select>--%>
                            </el-form-item>
                        </x-col>

                    </el-row>
                    <el-row>
                        <x-col>
                            <el-form-item label="单位性质">
                                <x-input v-model="info.coopProperty" name="单位性质" disabled/>
                            </el-form-item>
                        </x-col>
                        <x-col position="right">
                            <el-form-item label="内部关系">
                                <x-input v-model="info.innerRelationship" name="内部关系" disabled/>
                            </el-form-item>
                        </x-col>

                    </el-row>
                    <el-row>
                        <x-col>
                            <el-form-item label="合作周期">
                                <x-input v-model="info.workYears" name="合作周期" disabled></x-input>
                            </el-form-item>
                        </x-col>
                        <x-col position="right">
                            <el-form-item label="建设周期">
                                <x-input v-model="info.buildYears" name="建设周期" disabled></x-input>
                            </el-form-item>
                        </x-col>
                    </el-row>
                    <el-row>
                        <x-col>
                            <el-form-item label="总投资额">
                                <x-input v-model="info.sumAmount" name="总投资额" disabled></x-input>
                            </el-form-item>
                        </x-col>
                    </el-row>
                    <el-row>
                        <x-col position="full">
                            <el-form-item label="项目简介" prop="remark">
                                <x-input v-model="info.proRemarks" name="项目简介" type="textarea" :rows="4"
                                         disabled></x-input>
                            </el-form-item>
                        </x-col>
                    </el-row>
                </div>
            </div>
            <%--项目合作方--%>
            <div class="title">
                <h3>项目合作方</h3>
            </div>
            <div class="unit">
                <%-- <div class="unit_add">
                     <button class="layui-btn layuiadmin-btn-admin" type="button" data-type="add" @click="addSummary">
                         <i class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>添加合作单位
                     </button>
                 </div>--%>
                <div class="unit_center">
                    <%-- <div class="unit_img">
                         <div class="item" v-for="(item,index) in summary" :key="index" v-if="summary.length>1">
                             <img src="${ctx}/resources/images/del.png" alt="" @click="delSummary(index)">
                         </div>
                     </div>--%>
                    <el-table :data="summary" style="width: 100%" border>
                        <el-table-column prop="unit" label="合作单位" align="center">
                            <template slot-scope="scope">
                                <el-select v-model="scope.row.sgCoopId" filterable placeholder="请选择" disabled>
                                    <el-option v-for="item in coopInfoList" :key="item.id" :label="item.coopName"
                                               :value="item.id"></el-option>
                                </el-select>
                            </template>
                        </el-table-column>
                        <el-table-column prop="effect" label="单位作用" align="center">
                            <template slot-scope="scope">
                                <el-select v-model="scope.row.coopEffect" filterable placeholder="请选择" disabled>
                                    <el-option v-for="item in coopEffect" :key="item.code" :label="item.name"
                                               :value="item.code"></el-option>
                                </el-select>
                            </template>
                        </el-table-column>
                        <el-table-column prop="type" label="合作类型" align="center">
                            <template slot-scope="scope">
                                <el-select v-model="scope.row.cooperationType" filterable placeholder="请选择" disabled>
                                    <el-option v-for="item in cooperationType" :key="item.code" :label="item.name"
                                               :value="item.code"></el-option>
                                </el-select>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
            </div>
            <div class="title">
                <h3>项目投资构成</h3>
            </div>
            <div class="investment">
                <%-- <div class="investment_add">
                     <button class="layui-btn layuiadmin-btn-admin" type="button" @click.stop="addInvestment">
                         <i class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>添加子项
                     </button>
                 </div>--%>
                <%--  <div class="investment_top_del" v-if="itemName.length>1">
                      <div class="item"></div>
                      <div class="item" v-for="(item,index) in itemName" :key="index">
                          <img src="${ctx}/resources/images/del.png" alt="" @click="delInvestmentTop(index)">
                      </div>
                  </div>--%>
                <div class="investment_center">
                    <%--    <div class="investment_img">
                            <div class="item" v-for="(item,index) in investmentInfoVos" :key="index">
                                <img src="${ctx}/resources/images/del.png" alt="" @click="delInvestmentLeft(index)"
                                     v-if="item.isAdd">
                            </div>
                        </div>--%>
                    <el-table :data="investmentInfoVos" style="width: 100%" border ref="investment">
                        <el-table-column prop="name" label="名称" align="center">
                            <template slot-scope="scope">
                                <div v-if="scope.$index<=2||scope.row.name=='合计'">{{scope.row.name}}</div>
                                <div v-else>
                                    <%--                                hover--%>
                                    <el-popover placement="bottom" width="50" trigger="hover" style="opacity: 0">
                                        <div class="el-popover_item">
                                            <el-button type="button">添加费用</el-button>
                                        </div>
                                        <div class="el-popover_item">
                                            <el-button type="button" @click="addInvestmentList(scope.row)">添加子项
                                            </el-button>
                                        </div>
                                        <div slot="reference">
                                            <div style="cursor: pointer" v-if="!scope.row.isAdd">
                                                {{scope.row.name}}
                                            </div>
                                            <el-input v-else v-model="scope.row.name" placeholder="请选择费用"
                                                      disabled></el-input>
                                        </div>
                                    </el-popover>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column align="center" v-for="(item,index) in itemName "
                                         :key="index">
                            <template #header>
                                <el-input v-model="item.name" placeholder="请输入子项" disabled></el-input>
                            </template>
                            <template slot-scope="scope">
                                <template v-if="scope.row.name=='合计'">
                                    <el-input v-model="scope.row.list[index]" type="number" min="0" placeholder="请输入金额"
                                              disabled
                                              @input="investmentTotal" :disabled="true" style="color: #000"></el-input>
                                </template>
                                <template v-else>
                                    <el-input v-model="scope.row.list[index]" type="number" min="0" placeholder="请输入金额"
                                              disabled
                                              @input="investmentTotal"></el-input>
                                </template>
                            </template>
                        </el-table-column>
                        <el-table-column prop="type" label="合计" align="center" type="index" width="100">
                            <template slot-scope="scope">
                                <div v-if="scope.$index<=2"></div>
                                <div v-else>{{scope.row.total?scope.row.total:'0'}}</div>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
            </div>
            <%--回报机制--%>
            <div class="repay">
                <div class="title">
                    <h3>回报机制</h3>
                </div>
                <el-row>
                    <x-col position="full">
                        <el-form-item label="" prop="b1">
                            <el-radio-group v-model="info.backMech" disabled>
                                <el-radio label="1">政府付费</el-radio>
                                <el-radio label="2">可行性缺口补助</el-radio>
                                <el-radio label="3">使用者付费</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </x-col>
                </el-row>
                <el-row>
                    <el-col :span="6" :offset="2" class="mr-10">
                        <el-form-item label="工程费用下浮率">
                            <x-input size="small" type="number" min="0" v-model="info.downRate" disabled/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6" class="mr-10">
                        <el-form-item label="合理利润率">
                            <x-input size="small" type="number" min="0" v-model="info.profitRate" disabled/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6" class="mr-10">
                        <el-form-item label="投资回报率">
                            <x-input size="small" type="number" min="0" v-model="info.investBackRate" disabled/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="6" :offset="2" class="mr-10">
                        <el-form-item label="折现率">
                            <x-input size="small" type="number" min="0" v-model="info.discountRate" disabled/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6" class="mr-10">
                        <el-form-item label="建设期融资利率">
                            <x-input size="small" type="number" min="0" v-model="info.finRate" disabled/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6" class="mr-10">
                        <el-form-item label="融资回报率">
                            <x-input size="small" type="number" min="0" v-model="info.finBackRate" disabled/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="6" :offset="2" class="mr-10">
                        <el-form-item label="资本金回报率">
                            <x-input size="small" type="number" min="0" v-model="info.capitalBackRate" disabled/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6" class="mr-10">
                        <el-form-item label="总投资额">
                            <x-input size="small" type="number" min="0" v-model="info.sumAmount" disabled/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6" class="mr-10">
                        <el-form-item label="资本金比例">
                            <x-input size="small" type="number" min="0" v-model="info.capitalPercent" disabled/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="6" :offset="2" class="mr-10">
                        <el-form-item label="资本金数额">
                            <x-input size="small" type="number" min="0" v-model="info.capitalFund" disabled/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6" class="mr-10">
                        <el-form-item label="我方股权出资金额">
                            <x-input size="small" type="number" min="0" v-model="info.stockFund" disabled/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6" class="mr-10">
                        <el-form-item label="我方股权比例">
                            <x-input size="small" type="number" min="0" v-model="info.stockPercent" disabled/>
                        </el-form-item>
                    </el-col>
                </el-row>
            </div>
            <div class="title">
                <h3>项目风险</h3>
            </div>
            <div class="unit">
                <%-- <div class="unit_add">
                     <button class="layui-btn layuiadmin-btn-admin" type="button" data-type="add" @click="addRisk">
                         <i class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>添加风险点
                     </button>
                 </div>--%>
                <div class="unit_center">
                    <%--  <div class="unit_img">
                          <div class="item" v-for="(item,index) in riskTable" :key="index" v-if="riskTable.length>1">
                              <img src="${ctx}/resources/images/del.png" alt="" @click="delRisk(index)">
                          </div>
                      </div>--%>
                    <el-table :data="riskTable" style="width: 100%" border>
                        <el-table-column prop="unit" label="风险描述" align="center">
                            <template slot-scope="scope">
                                <el-input v-model="scope.row.riskDesc" placeholder="请输入风险点" disabled></el-input>
                            </template>
                        </el-table-column>
                        <el-table-column prop="effect" label="风险等级" align="center">
                            <template slot-scope="scope">
                                <el-select v-model="scope.row.riskLevel" placeholder="请选择">
                                    <el-option v-for="item in riskLevel" :key="item.code" :label="item.name" disabled
                                               :value="item.code"></el-option>
                                </el-select>
                            </template>
                        </el-table-column>
                        <el-table-column prop="type" label="处理策略" align="center">
                            <template slot-scope="scope">
                                <el-select v-model="scope.row.solveWay" placeholder="请选择">
                                    <el-option v-for="item in riskSolveWay" :key="item.code" :label="item.name" disabled
                                               :value="item.code"></el-option>
                                </el-select>
                            </template>
                        </el-table-column>
                        <el-table-column prop="type" label="最新进展" align="center">
                            <template slot-scope="scope">
                                <el-input v-model="scope.row.latestProgress" placeholder="请描述风险进展" disabled></el-input>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
            </div>
            <el-row>
                <x-col position="full">
                    <el-form-item label="项目优点">
                        <x-input v-model="info.proMerit" type="textarea" :rows="4" disabled></x-input>
                    </el-form-item>
                </x-col>
            </el-row>
            <el-row>
                <x-col position="full">
                    <el-form-item label="其他说明">
                        <x-input v-model="info.proOthers" type="textarea" :rows="4" disabled></x-input>
                    </el-form-item>
                </x-col>
            </el-row>
            <div class="title">
                <h3>底线标准情况</h3>
            </div>
            <div class="unit">
                <div class="unit_center">
                    <el-table :data="standardTable" style="width: 100%" border>
                        <el-table-column prop="unit" label="标准名称" align="center">
                            <template slot-scope="scope">
                                {{scope.row.nowName}}
                            </template>
                        </el-table-column>
                        <el-table-column prop="effect" label="标准值" align="center">
                            <template slot-scope="scope">
                                {{scope.row.nowValue}}
                            </template>
                        </el-table-column>
                        <el-table-column prop="type" label="当前进度" align="center">
                            <template slot-scope="scope">
                                {{scope.row.nowProgress}}
                            </template>
                        </el-table-column>
                        <el-table-column prop="type" label="结论" align="center">
                            <template slot-scope="scope">
                                {{scope.row.resultMsg}}
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
            </div>
            <div class="title">
                <h3>项目附件信息</h3>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width:350px;">支持pdf、excel、word、图片资料，可上传多个</label>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">项目可研报告</label>
                <div class="layui-input-block">
                    <div class="layui-upload">
                        <%--                        <button type="button" class="layui-btn" type="button" id="1-upload-more">上传</button>--%>
                        <div class="layui-upload-list" id="1-upload-more-list">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">两评一案</label>
                <div class="layui-input-block">
                    <div class="layui-upload">
                        <%--                        <button type="button" class="layui-btn" type="button" id="2-upload-more">上传</button>--%>
                        <div class="layui-upload-list" id="2-upload-more-list">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">其他资料</label>
                <div class="layui-input-block">
                    <div class="layui-upload">
                        <%--                        <button type="button" class="layui-btn" type="button" id="3-upload-more">上传</button>--%>
                        <div class="layui-upload-list" id="3-upload-more-list">
                        </div>
                    </div>
                </div>
            </div>
            <%--审批信息--%>
            <div class="title">
                <h3>审批信息</h3>
            </div>
            <div class="approve">
                <el-row>
                    <x-col position="left">
                        <el-form-item label="是否继续跟踪">
                            <x-select v-model="info.isTrack" name="继续跟踪" :options="traceOptions"></x-select>
                        </el-form-item>
                    </x-col>
                    <x-col position="full">
                        <el-form-item label="审批意见">
                            <x-input v-model="auditMsg" type="textarea" :rows="4"></x-input>
                        </el-form-item>
                    </x-col>
                </el-row>
            </div>
        </el-form>
    </div>
</div>
<script src="${ctx}/resources/vue-element-lib/jquery.js"></script>
<script>
    let fileArr = [];
    var staticPath = '${fileHttpPre}';
    layui.config({
        base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set', 'upload'], function () {
        var $ = layui.$, upload = layui.upload;
        ;(function () {
            //定义构造函数
            var Upfile = function (ele, type, opt) {
                this.defaults = {
                    //elem:‘#uploadPic‘	//绑定元素
                    elem: $(ele)	//绑定元素
                    , url: basePath + '/contractInfo/uploadAtt/',
                    data: {
                        types: type
                    },
                    multiple: true,
                    accept: 'file',
                    acceptMime: 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf',

                    method: 'post',
                    before: function (obj) { //obj参数包含的信息
                        layer.load(); //上传loading
                    },
                    done: function (res) {
                        //如果上传失败
                        if (res.code > 0) {
                            layer.closeAll('loading'); //关闭loading
                            return layer.msg(res.msg, {icon: 7});
                        }
                        //上传完毕
                        if (res.entity != null && res.entity.length > 0) {
                            fileArr.push(res.entity[0])
                            for (var i in res.entity) {
                                var contractInfo = res.entity[i];
                                var arr = contractInfo.split("|");
                                var imgSrc = "";
                                var suffix = arr[1].substring(arr[1].lastIndexOf(".") + 1, arr[1].length);
                                if (suffix == 'jpg' || suffix == 'png') {
                                    imgSrc = "${fileHttpPre}/" + arr[3];
                                } else {
                                    imgSrc = "${ctx}/resources/images/" + suffix + ".jpg";
                                }
                                $('#' + type + '-upload-more-list')
                                    .append('<div class="layui-upload-img-div" id="upload_img_' + arr[2] + '"><img src="' + imgSrc + '" title="'
                                        + arr[1] + '" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\'' + "${fileHttpPre}"
                                        + arr[3] + '\');">查看</a></div><p>' + arr[1] + '</p><input type="hidden" value="'
                                        + contractInfo + '" id="fileAtt_' + arr[2] + '" name="fileAtts" ></input></div> ');
                            }
                        }
                    },
                    allDone: function (obj) { //当文件全部被提交后，才触发
                        layer.closeAll('loading'); //关闭loading
                    },
                    error: function () {
                        layer.closeAll('loading'); //关闭loading
                        //上传失败
                        layer.msg("上传失败，请稍后再试~", {icon: 7});
                    }
                }
                this.options = $.extend({}, this.defaults, opt);
            };

            //定义方法
            Upfile.prototype = {
                init: function () {
                    var _this = this;
                    return layui.use('upload', function () {
                        var upload = layui.upload;

                        //执行实例
                        var uploadInst = upload.render(_this.options);
                    });
                }
            };

            //在插件中使用对象
            $.fn.upfile = function (options) {
                var upfile = new Upfile(this, options);
                return upfile.init();
            }
        })();
        //上传文件
        $('#1-upload-more').upfile(1);
        $('#2-upload-more').upfile(2);
        $('#3-upload-more').upfile(3);
    });

    //删除文件
    function del(index) {
        layui.$("#fileAtt_" + index).remove();
        layui.$("#upload_img_" + index).remove();
    }

    //根据url查看文件
    function showImg(url) {
        var openWin = window.open(url, '', 'left=410,height=768, width=1024, top=200,  toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
    }

    /*核心*/
    new Vue({
        el: '#app',
        data() {
            return {
                auditMsg: '',
                id: '',
                options: [],
                info: {
                    proName: '',//项目名称
                    proTypes: '',//项目类型
                    isInStore: '',//入库情况
                    proFormat: '',//项目业态
                    omYears: '',//运营周期
                    refProvinceId: '',//省 id
                    refCityId: '',//市 id
                    refAreaId: '',//区id
                    address: '',//详细地址
                    innerRelationship: '',//内部关系
                    coopProperty: '',//单位性质
                    unitId: '',//业主单位Id
                    fromChannel: '',//项目渠道
                    workYears: '',//合作周期
                    buildYears: '',//建设周期
                    sumAmount: '',//总投资额
                    proRemarks: '',//项目简介
                    //回报机制
                    downRate: '',//工程费用下浮率
                    profitRate: '',//合理利润率
                    investBackRate: '',//投资回报率
                    discountRate: '',//折现率
                    finRate: '',//建设期融资利率
                    finBackRate: '',//融资回报率
                    capitalBackRate: '',//资本金回报率
                    capitalPercent: '',//资本金比例
                    capitalFund: '',//资本金数额
                    stockFund: '',//我方股权出资金额
                    stockPercent: '',//我方股权比例
                    //项目风险
                    proMerit: '',//项目优点
                    proOthers: '',//其他说明
                    isTrack: '',//是否继续追踪
                    applyOpinion: '',//审批意见


                    backMech: '',
                },
                coopInfoList: [],//合作单位
                coopEffect: [],//单位作用
                cooperationType: [],//合作类型
                proFormaType: [],//项目业态
                projectChannel: [],//项目渠道
                projectType: [],//项目类型
                riskLevel: [],//风险等级
                storageSituation: [],//入库情况
                province: [],//省
                city: [],//市
                area: [],//区
                summary: [],//合作单位 sgCoopId 合作单位ID---coopEffect 单位作用 --- setCooperationType --合作类型

                riskSolveWay: [],//处理策略
                //项目类型
                projectType: [],
                //入库情况
                storageSituation: [],
                projectInfo: {},
                // 是否追踪
                traceOptions: [
                    {name: '继续跟踪', code: 0},
                    {name: '停止跟踪', code: 1}
                ],
                summary: [], // sgCoopId 合作单位ID---coopEffect 单位作用 --- setCooperationType --合作类型

                itemName: [{name: '子项名称1'},],
                investmentInfoVos: [
                    {name: '合作周期', list: [0], total: 0,},
                    {name: '建设周期', list: [0], total: 0,},
                    {name: '运营周期', list: [0], total: 0,},
                    {name: '1.建安工程费用', list: [0], total: 0,},
                    {name: '2.设备购置费用', list: [0], total: 0,},
                    {name: '3.工程建设其他', list: [0], total: 0,},
                    {name: '3.1征地拆迁费', list: [0], total: 0,},
                    {name: '4.预备费', list: [0], total: 0,},
                    {name: '5.建设期利息', list: [0], total: 0,},
                    {name: '合计', list: [0], total: 0,}],
                owner: [],      //业主单位
                //项目风险点
                riskTable: [],//riskDesc:风险描述 riskLevel:等级 solveWay:处理策略 latestProgress:最新进展
                //底线标准情况
                standardTable: []//name:标准名称 value:标准值 schedule:当前进度  conclusion:结论
            }
        },
        created() {
            let that = this;
            this.getDrop();//获取下拉
            this.getAddress()//获取地址
            this.queryCoopInfo();//获取业主单位
            that.id = "${id}";
            if (that.id) {
                that.queryCollectDetail();
            }
        },
        mounted() {

        },
        methods: {
            // 查看详情
            queryCollectDetail() {
                let that = this;
                $.ajax({
                    type: 'post',
                    url: basePath + '/preProject/queryPreDetail',  //请求数据接口
                    data: {
                        id: that.id
                    },
                    success: function (result) {
                        console.log(result);
                        that.info = result.entity.projectInfo;
                        that.info.isTrack = Number(that.info.isTrack);
                        that.getAddress(that.info.refProvinceId, 1)//获取地址
                        that.getAddress(that.info.refCityId, 2)//获取地址
                        that.riskTable = result.entity.riskTable;
                        that.summary = result.entity.summaryCoops;
                        that.standardTable = result.entity.standardTable;
                        console.log(that.standardTable)
                        that.showFile(result.entity.fileAtt);
                        if (result.entity.investmentInfoVos.length > 0) {
                            that.itemName = result.entity.itemName;
                            that.investmentInfoVos = result.entity.investmentInfoVos;
                        }
                        let arr = [];
                        that.summary.map((el, index) => {
                            if (el.coopEffect == -1) {
                                arr = that.summary.splice(index, 1)
                            }
                        })
                        console.log(arr)
                        that.info.unitId = arr[0].sgCoopId;
                    }
                });
            },
            queryCoopInfo() {
                let that = this;
                $.ajax({
                    type: 'post',
                    url: basePath + '/proSell/queryCoopInfo',  //请求数据接口
                    data: {},
                    success: function (result) {
                        console.log(result);
                        that.owner = result;
                    }
                });
            },
            showFile(fileList) {
                if (fileList && fileList.length > 0) {
                    fileArr = fileList;
                    for (let i in fileList) {
                        let contractInfo = fileList[i];
                        let arr = contractInfo.split("|");
                        let imgSrc = "";
                        let suffix = arr[1].substring(arr[1].lastIndexOf(".") + 1, arr[1].length);
                        if (suffix == 'jpg' || suffix == 'png') {
                            imgSrc = "${fileHttpPre}/" + arr[3];
                        } else {
                            imgSrc = "${ctx}/resources/images/" + suffix + ".jpg";
                        }
                        $('#' + arr[0] + '-upload-more-list')
                            .append('<div class="layui-upload-img-div" id="upload_img_' + arr[2] + '"><img src="' + imgSrc + '" title="'
                                + arr[1] + '" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\'' + "${fileHttpPre}"
                                + arr[3] + '\');">查看</a></div><p>' + arr[1] + '</p><input type="hidden" value="'
                                + contractInfo + '" id="fileAtt_' + arr[2] + '" name="fileAtts" ></input></div> ');
                    }
                }
            },
            error(text) {
                this.$message({
                    message: text,
                    type: 'warning'
                });
            },
            //获取下拉
            getDrop() {
                let that = this;
                $.ajax({
                    type: 'post',
                    url: basePath + '/collectProject/getDrop',  //请求数据接口
                    data: {},
                    success: function (result) {
                        that.coopInfoList = result.entity.coopInfoList;//合作单位
                        that.coopEffect = result.entity.coopEffect;//单位作用
                        that.cooperationType = result.entity.cooperationType;//合作类型
                        that.proFormaType = result.entity.proFormaType;//项目业态
                        that.projectChannel = result.entity.projectChannel;//项目渠道
                        that.projectType = result.entity.projectType;//项目类型
                        that.riskLevel = result.entity.riskLevel;//风险等级
                        that.riskSolveWay = result.entity.riskSolveWay;//处理策略
                        that.storageSituation = result.entity.storageSituation;//入库情况
                        //底线标准情况
                        // that.standardTable = result.entity.standardTable && result.entity.standardTable.length > 0 ? result.entity.standardTable : [];//入库情况
                    }
                });
            },
            //获取地址
            getAddress(id, type = 0) {
                let that = this;
                $.ajax({
                    type: 'post',
                    url: basePath + '/collectProject/getAddress',  //请求数据接口
                    data: {
                        id: (id ? id + ',' : '') + (type ? type : '0')
                    },
                    success: function (result) {
                        console.log(result)
                        if (type == 0) {
                            that.province = result.entity;//省
                            console.log(111)
                            console.log(that.province)
                        } else if (type == 1) {
                            that.city = result.entity//市
                        } else {
                            that.area = result.entity//区
                        }
                    }
                });
            },
            selProvince(id) {
                this.city = [];
                this.area = [];
                this.info.refCityId = '';//市 id
                this.info.refAreaId = '';//区id
                this.info.address = '';//详细地址
                this.getAddress(id, 1)//获取地址

            },
            selCity(id) {
                this.area = [];
                this.info.refAreaId = '';//区id
                this.info.address = '';//详细地址
                this.getAddress(id, 2)//获取地址
            },
            //添加合作单位
            addSummary() {
                let obj = {
                    sgCoopId: '',
                    coopEffect: '',
                    cooperationType: ''
                }
                this.summary.push(obj);
            },
            delSummary(index) {
                this.summary.splice(index, 1)
            },
            //删除子项
            delInvestmentTop(index) {
                this.itemName.splice(index, 1);
                this.investmentInfoVos.map(el => {
                    el.list.splice(index, 1);
                })
                this.investmentTotal();
            },
            delInvestmentLeft(index) {
                this.investmentInfoVos.splice(index, 1);
                this.investmentTotal();
            },
            addInvestment() {
                if (this.itemName.length < 6) {
                    this.itemName.push({name: ''});
                    this.investmentInfoVos.map(el => {
                        el.list.push(0);
                    })
                }
            },
            //合计 计算数字
            investmentTotal() {
                console.log(this.investmentInfoVos);
                //计算每一列的相加
                let arr1 = [];
                this.investmentInfoVos.map((el, idx) => {
                    if (el.name != '合计' && idx > 2) {
                        el.list.map((el1, index) => {
                            if (!arr1[index]) {
                                arr1[index] = 0;
                                arr1[index] = arr1[index] + Number(el1)
                            } else {
                                arr1[index] = arr1[index] + Number(el1)
                            }
                        })
                    }
                    if (el.name == '合计') {
                        el.list = arr1
                    }
                })
                let sum = 0;
                // 计算每一行的总和
                this.investmentInfoVos.map((el, idx) => {
                    let num = 0;
                    el.list.map(el1 => {
                        num += Number(el1) ? Number(el1) : 0
                    })
                    el.total = num ? num : 0;
                    if (el.name != '合计' && idx > 2) {
                        sum += el.total;
                    } else {
                        el.total = sum
                    }
                })
                console.log(arr1);
            },
            addInvestmentList(e) {
                for (let x in this.investmentInfoVos) {
                    if (this.investmentInfoVos[x].name == e.name) {
                        console.log(this.investmentInfoVos[x].name)
                        let obj = {
                            name: '',
                            list: [],
                            total: 0,
                            isAdd: true,
                        }

                        this.itemName.map(el => {
                            let num = 0
                            obj.list.push(num)
                        })
                        this.investmentInfoVos.splice(Number(x) + 1, 0, obj)
                    }
                }
            },
            //添加风险点
            addRisk() {
                let obj = {description: '', grade: '', strategy: '', progress: ''};
                this.riskTable.push(obj);
            },
            //删除风险点
            delRisk(index) {
                this.riskTable.splice(index, 1)
            },
            //保存
            save(type) {
                let that = this;
                $.ajax({
                    type: 'post',
                    url: basePath + '/preProject/auditProcess',  //请求数据接口
                    data: {
                        id: that.info.id,  //info里面获取
                        processId: that.info.processId,  //info里面获取
                        status: type,  //0=驳回，1=通过
                        auditMsg: that.auditMsg  //填写的审批信息
                    },
                    success: function (result) {
                        if (result.success) {
                            that.$message({
                                message: result.msg,
                                type: 'success'
                            });
                        } else {
                            that.$message.error(result.msg);
                        }
                    }
                });
            }
        }
    })
</script>
</body>
</html>

